package com.example.demo.repository;

import com.example.demo.domain.Goods;
import com.example.demo.domain.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import java.util.List;

@Mapper
@Repository
public interface OrderMapper
{


    //查询用户相关订单 state 0:购物车 1：支付  2:后台同意发货 3.付款 4.退货 5.后台同意退货

    //获取购物车订单
    List<Order> getCartOrderByUid(@Param("uid") Integer uid,@Param("start")Integer start,@Param("end") Integer end);

    //查询非购物车订单
    List<Order> getNonCartOrderByUid(@Param("uid") Integer uid,@Param("start")Integer start,@Param("end") Integer end);

    //更新 order state
    void saveOrderState(@Param("id") Integer id,@Param("state") Integer state);


    public List<Order> getOrder(Integer state);

    public List<Order> getSearch(@Param("searchText") String searchText,@Param("state")Integer state);

    public List<Order> getHistoryOrders();

    public List<Order> getHistoryOrderSearch(String searchText);

    @Select("select id from orders where uid=#{uid} and times=#{times} and gid=#{gid} and goodsNum=#{goodsNum}")
    public Integer getIdByOrder(@Param("uid") Integer uid,@Param("times") String times,@Param("gid")Integer gid,@Param("goodsNum")Integer goodsNum);

    // 查
    public Order getOrderById(Integer id);

    //查询基本信息
    Order getBaseOrderById(Integer id);

    //增
    void addOrder(Order order);

    // 删
    void delOrderById(Integer id);

    // 改
    void saveOrder(Order order);



}
